﻿using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using U3DSceneEditor;

public class RectangUtil : MonoBehaviour
{

    //  单元格长度
    public float cell_L = 1;
    //  单元格宽度
    public float cell_H = 1;

    //  区域长
    public float area_width = 50;
    //  区域宽
    public float area_height = 50;

    //int[][] array = null;
    //public int hori = 0;
    //public int vert = 0;
    //    hori = area_width / cell_L;
    //    vert = area_height / cell_H;

    //    array = new int[hori, vert] { 0 };

    public Dictionary<Vector3, Vector3> dicHori = new Dictionary<Vector3, Vector3>();
    public Dictionary<Vector3, Vector3> dicVert = new Dictionary<Vector3, Vector3>();

    // Use this for initialization
    void Start ()
    {
        {
            Vector3 hori_begin = Vector3.zero;
            Vector3 hori_begin_end = Vector3.zero;

            while (hori_begin.x < area_width)
            {
                hori_begin_end.x = hori_begin.x;
                hori_begin_end.y = area_height;

                dicHori.Add(hori_begin, hori_begin_end);

                hori_begin.x += cell_L;

            }

        }

        {
            Vector3 vert_begin = Vector3.zero;
            Vector3 vert_begin_end = Vector3.zero;
            while (vert_begin.y < area_height)
            {
                vert_begin_end.x = area_width;
                vert_begin_end.y = vert_begin.y;

                dicVert.Add(vert_begin, vert_begin_end);

                vert_begin.y += cell_H;

            }

        }
    }

    // Update is called once per frame
    void Update()
    {
        ShowGizmoz();
    }

    void ShowGizmoz()
    {
        foreach (KeyValuePair<Vector3, Vector3> line in dicHori)
        {
            GLGizmos.DrawLine(line.Key, line.Value, Color.black);
        }

        foreach (KeyValuePair<Vector3, Vector3> line in dicVert)
        {
            GLGizmos.DrawLine(line.Key, line.Value, Color.black);
        }
    }

}
